function Corr_out = corr_caculate(fd,a,Corr,n,settings)

Corr_out = 0;
% 参数
fp = [];

deltac = [];
for i = 1:n
    fp(i) = 2*fd/i;
    T(i) = 1/fp(i);
    deltac(i) = (a(i)/1e9)*fp(i);
end
for i = 1:n
    J_out(i) = abs(besselj(1,deltac(i))/besselj(0,deltac(i)));

end
% J_out = 10*log10(J_out);
% x = 1:7;
% plot(x,J_out);
% xlabel("群时延Fourier级数i")
% ylabel("相对幅度/dB")
% title("各级群时延第一对多径信号与主相关峰幅度比")
% grid on
iter = ones(1,n)*-3;
iter(1) = -7;
while  1
    tao_f = 0;
    J_f = 1;
    for i = 1:n
         tao_f = tao_f + iter(i)*T(i);
         yanchi = ceil(tao_f*settings.fs);
         J_f = J_f * besselj(iter(i),deltac(i));
         if abs(yanchi)>1*settings.NumPerCode || abs(J_f) < 1e-6
            break
         end
         if yanchi < 0
            Corr_yan = [zeros(abs(yanchi),1)',Corr(1:end-abs(yanchi))];
         else
            Corr_yan = [Corr(yanchi+1:end),zeros(yanchi,1)'];
         end
        if i==n
            Corr_out = Corr_out+J_f*Corr_yan;
        end
         
    end
    % 循环计数累加
    for k = linspace(n,1,n)
        iter(k) = iter(k) + 1;
        if iter(1) == 8
            return
        end
        if iter(k)>3 && k ~= 1
            iter(k) = -3;
        else
            break
        end
    
    end


end








end